package com.ruoyi.web.controller.rgpp;

import java.util.List;

import com.github.abel533.echarts.Option;
import com.github.abel533.echarts.axis.CategoryAxis;
import com.github.abel533.echarts.axis.ValueAxis;
import com.github.abel533.echarts.code.AxisType;
import com.github.abel533.echarts.series.Bar;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.rgpp.domain.JmrNum;
import com.ruoyi.rgpp.service.IJmrNumService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;


/**
 * 统计图标Controller
 * 
 * @author ruoyi
 * @date 2022-06-16
 */
@Controller
@RequestMapping("/rgpp/num")
public class JmrNumController extends BaseController
{
    private String prefix = "rgpp/num";

    @Autowired
    private IJmrNumService jmrNumService;

    @RequiresPermissions("rgpp:num:view")
    @GetMapping()
    public String num(ModelMap mmp)
    {
        mmp.put("num",jmrNumService.selectList());
        return prefix + "/num";
    }

    /**
     * 查询统计图标列表
     */
    @RequiresPermissions("rgpp:num:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(JmrNum jmrNum)
    {
        startPage();
        List<JmrNum> list = jmrNumService.selectJmrNumList(jmrNum);
        return getDataTable(list);
    }

    /**
     * 导出统计图标列表
     */
    @RequiresPermissions("rgpp:num:export")
    @Log(title = "统计图标", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(JmrNum jmrNum)
    {
        List<JmrNum> list = jmrNumService.selectJmrNumList(jmrNum);
        ExcelUtil<JmrNum> util = new ExcelUtil<JmrNum>(JmrNum.class);
        return util.exportExcel(list, "统计图标数据");
    }

    /**
     * 新增统计图标
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存统计图标
     */
    @RequiresPermissions("rgpp:num:add")
    @Log(title = "统计图标", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(JmrNum jmrNum)
    {
        return toAjax(jmrNumService.insertJmrNum(jmrNum));
    }

    /**
     * 修改统计图标
     */
    @RequiresPermissions("rgpp:num:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        JmrNum jmrNum = jmrNumService.selectJmrNumById(id);
        mmap.put("jmrNum", jmrNum);
        return prefix + "/edit";
    }

    /**
     * 修改保存统计图标
     */
    @RequiresPermissions("rgpp:num:edit")
    @Log(title = "统计图标", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(JmrNum jmrNum)
    {
        return toAjax(jmrNumService.updateJmrNum(jmrNum));
    }

    /**
     * 删除统计图标
     */
    @RequiresPermissions("rgpp:num:remove")
    @Log(title = "统计图标", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(jmrNumService.deleteJmrNumByIds(ids));
    }
}
